﻿using Data.Service;
using Model;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SYT.AliApiHandle;
using SYT.Web.HelpService;

namespace SYT.Web.AppTaskEngine
{
    public class AutoResendJob : IJob
    {

        public void Execute(IJobExecutionContext context)
        {
            try
            {
                HelpFunction.WriteLog("每日凌晨四点对商品自动重发" + DateTime.Now.ToString());
                List<Users> list = UsersData.GetUsers("AutoResend");
                if (list != null && list.Count > 0)
                {
                    foreach (Users user in list)
                    {
                        string refresh_token = user.refresh_token;

                        //根据当前用户对象，查询到最新的临时令牌。
                        bool isone = true;
                        string newaccess_token = GetToken.ExchangeAccessToken(user.refresh_token, out isone);

                        if (!string.IsNullOrEmpty(newaccess_token))
                        {
                            Dictionary<string, string> dic = new Dictionary<string, string>();
                            dic.Add("pageNo", "1");
                            dic.Add("pageSize", "10");
                            dic.Add("statusList", "published");
                            //ProductManage.AutoResend(dic, newaccess_token);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                HelpFunction.WriteLog("每日凌晨四点对商品自动重发报错：" + ex.Message + "————时间：" + DateTime.Now.ToString());
            }
        }
    }
}